#!/bin/bash

#if $1 contains $2
function strstr() {
	 "${1#*$2*}" != "$1"
}

if [ $# -ne 2 ]; then 
	echo "Usage:
	$0 <peer1_id> <peer2_id>" 1>&2
	exit 1
fi 

PRINT=0
peer1="=$1[[:space:]]"
peer2="=$2[[:space:]]"
#set -x
dbus-monitor --system |while IFS="" read line; do
	if  [ "${line#*$peer1}" != "$line" -a  "${line#*$peer2}" != "$line"  ]; then
		echo "$line"
		PRINT=1
	elif [ "${line#[[:space:]]}"  != "$line" ] ; then
		[ $PRINT -eq 1 ] && echo "$line" 
	
	else
		PRINT=0
	fi

done
